# 先导入 requests 包
import requests

"""
# 获取地址信息
baiduResponse = requests.get("https://www.yueshushu.top")

# 打印出内容, 需要对内容 content 进行解码
# print(baiduResponse.content.decode())

# 使用具体的编码
print(baiduResponse.content.decode('utf-8'))

"""
#  Get 请求无参数

# get1 = requests.get("https://www.yueshushu.top/StockApi/stock/listDbType")
# print(get1.content.decode('utf-8'))

# Get 请求有参数,拼接字符串形式的

# get2 = requests.get("https://hq.sinajs.cn/list=sz123174")
"""
print("Get 请求有 参数")
params3 = {"code": "002762", "type":1}
get3 = requests.get("https://www.yueshushu.top/StockApi/stockCrawler/getStockInfo",params= params3)
print(get3.content.decode())

"""


# post 请求  3w 参数
"""
print("post 请求  3w 参数")
data1 = {"pageNum":1, "pageSize":15}
# post1 = requests.post("https://www.yueshushu.top/StockApi/jobInfo/list",data = data1);
# print(post1.content.decode())


"""

"""
print("post 请求 json 参数")
data2 = {"pageNum":1, "pageSize":15}
post2 = requests.post("https://www.yueshushu.top/StockApi/jobInfo/list",json= data2)
print(post2.content.decode())
"""

"""
上面是获取接口信息,获取到之后，接下来对数据进行提取
"""
import re
yueshushuResponse = requests.get("https://www.yueshushu.top")
yueshushuContent = yueshushuResponse.content.decode()
# -- 查询出 title 对应的信息
title = re.search('title>(.*?)</',yueshushuContent,re.S).group(1)
print('标题:' +title)
# 查询出具体的内容
content = re.search('<p style="padding-bottom: 30px;">(.*?)</',yueshushuContent,re.S).group(1)
print('内容'+ content)
tbody = re.search('tbody>(.*?)</tbody>',yueshushuContent,re.S).group(1)
print('展示信息:'+ tbody)


